<?php
namespace common\services\logistics;

use linslin\yii2\curl\Curl;
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
use Yii;
/**
 * 阿里云物流
 */

class LogisticsApiAliyun {


    /**
     * 阿里云物流查询
     * 参考地址 https://market.aliyun.com/products/57126001/cmapi021863.html?spm=5176.730005.result.2.5cf4123eXstU3t&innerSource=search_%E5%BF%AB%E9%80%92%E7%89%A9%E6%B5%81%E6%9F%A5%E8%AF%A2#sku=yuncode1586300000
     * @param string $no 订单号
     *
     * @return mixed
     */
    public static function queryLogistics($no = '') {

        $apiUrl = 'https://wuliu.market.alicloudapi.com/kdi';

        $appCode = Yii::$app->params['ALIYUN_MARKET_APP_CODE'];

        $curl = new Curl();
        $curl->setHeader('Authorization', "APPCODE " . $appCode);
        $params['no'] = $no;
        $curl->setGetParams($params);
        $res = $curl->get($apiUrl);
        $res = json_decode($res, true);
        return $res;
    }



}